package com.region.common.adapter.json;

import java.lang.reflect.Type;

/**
 * The Json Adapter, JSON adapters include Jackson and Gson Only
 *
 * @author liujeiyu
 * @date 2023/5/28 13:50
 * @desciption
 */
public interface JSONAdapter<T> {

    /**
     * Get the adaptation object
     *
     * @return
     */
    T getTarget();

    /**
     * Converting objects to json strings
     *
     * @param object
     * @return
     */
    String toJSONString(Object object);

    /**
     * Convert a json string to an object
     *
     * @param json
     * @return
     */
    Object toObject(String json);

    /**
     * Convert a json string to an object
     *
     * @param json
     * @return
     */
    <K> K toObject(String json, Class<K> clazz);

    /**
     * Convert a json string to an object
     *
     * @param json
     * @return
     */
    Object toObject(String json, Type type);

}
